Apache Wicket

Apache Wicket
Developer(s) Apache Software Foundation
Stable release 1.5.3 / November 14, 2011; 3 months ago (2011-11-14)[1]
Development status Active
Written in Java
Operating system Cross-platform (Java Virtual Machine)
Type Web application framework
License Apache License 2.0
Website http://wicket.apache.org

Apache Wicket, commonly referred to as Wicket, is a lightweight component-based web application framework for the Java programming language conceptually similar to JavaServer Faces and Tapestry. It was originally written by Jonathan Locke in April 2004. Version 1.0 was released in June 2005. It graduated into an Apache top-level project in June 2007.[2]

Contents

Rationale

Traditional MVC frameworks work in terms of whole requests and whole pages. In each request cycle, the incoming request is mapped to a method on a controller object, which then generates the outgoing response in its entirety, usually by pulling data out of a model to populate a view written in specialised template markup. This keeps the application's flow-of-control simple and clear, but can make code reuse in the controller difficult.

Design

Wicket, on the other hand, is closely patterned after stateful GUI frameworks such as Swing. Wicket applications are trees of components, which use listener delegates to react to HTTP requests against links and forms in the same way that Swing components react to mouse and keystroke events. Wicket is categorized as a component-based framework.[3]

Wicket uses plain XHTML for templating (which enforces a clear separation of presentation and business logic and allows templates to be edited with conventional WYSIWYG design tools[4]). Each component is bound to a named element in the XHTML and becomes responsible for rendering that element in the final output. The page is simply the top-level containing component and is paired with exactly one XHTML template. Reuseable parts of pages may be abstracted into components called panels, which can then be pulled whole into pages or other panels with a special tag.

Each component is backed by its own model, which represents the state of the component. The framework does not have knowledge of how components interact with their models, which are treated as opaque objects automatically serialized and persisted between requests. More complex models, however, may be made detachable and provide hooks to arrange their own storage and restoration at the beginning and end of each request cycle. Wicket does not mandate any particular object-persistence or ORM layer, so applications often use some combination of Hibernate objects, EJBs or POJOs as models.

Example

A Hello World Wicket application, with four files:

HelloWorld.html
The XHTML template.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"
      xml:lang="en" lang="en"> 
 
<body>
    <span wicket:id="message" id="message">Message goes here</span>
</body>
</html>
HelloWorld.java
The page component that will be bound to the template. It, in turn, binds a child component (the Label component named "message").
package org.wikipedia.wicket;
 
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
 
public class HelloWorld extends WebPage {
    /**
     * Constructor
     */
    public HelloWorld() {
        add(new Label("message", "Hello World!"));
    }
}
HelloWorldApplication.java
The main application class, which routes requests for the homepage to the HelloWorld page component.
package org.wikipedia.wicket;
 
import org.apache.wicket.protocol.http.WebApplication;
 
public class HelloWorldApplication extends WebApplication {
    /**
     * Constructor.
     */
    public HelloWorldApplication() {
    }
 
    /**
     * @see org.apache.wicket.Application#getHomePage()
     */
    public Class getHomePage() {
        return HelloWorld.class;
    }
}
web.xml
The servlet application Deployment Descriptor, which installs Wicket as the default handler for the servlet and arranges for HelloWorldApplication to be instantiated at startup.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns="http://java.sun.com/xml/ns/javaee" 
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                             http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         id="WebApp_ID" version="2.5">
    <display-name>Wicket Example</display-name>
    <filter>
        <filter-name>HelloWorldApplication</filter-name>
        <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
            <param-name>applicationClassName</param-name>
            <param-value>org.wikipedia.wicket.HelloWorldApplication</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>HelloWorldApplication</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

Components

http://wicketstuff.org/wicket14/compref/

Releases

Release Date Notes
1.3.7 2009-07-30 [5]
1.4 2009-07-30 " ... a departure from the past where we leave Java 1.4 behind and we require Java 5 as the minimum JDK version. By moving to Java 5 as the required minimum platform, we were able to utilize Java 5 idioms and increase the type safety of our APIs." [6]
1.4.1 2009-08-21 [7]
1.4.9 2010-05-24 "... over fifteen bug fixes and improvements" [8]
1.4.10 2010-08-11 "... over thirty bug fixes and improvements." [9]
1.4.16 2011-02-25 "This is primarily a minor bugfix release on the 1.4.x (stable) branch." [10]
1.4.17 2011-04-02 "This is primarily a minor bugfix release on the 1.4.x (stable) branch." [11]
1.4.18 2011-08-09 "This is primarily a minor bugfix release on the 1.4.x (stable) branch." [12]
1.4.19 2011-10-19 "This is primarily a minor bugfix release on the 1.4.x (stable) branch." [13]
1.5.0 2011-09-07 "Apache Wicket 1.5 has been in development for the last two years and brings many improvements over previous versions." [14]
1.5.1 2011-09-29 "... over 40 bug fixes and 15 improvements."[15]
1.5.2 2011-10-24 "... over 25 bug fixes and 5 improvements."[16]
1.5.3 2011-11-14 "... over 40 bug fixes and improvements."[17]
1.6 2011-12 (planned) Java 6 [18]

See also

References

  1. ^ http://wicket.apache.org/2011/10/24/wicket-1.5.2-released.html
  2. ^ Dashorst, Martijn (2007-07-20). "Wicket graduates from Apache Incubation". http://martijndashorst.com/blog/2007/06/20/3-2-1. Retrieved 2008-03-07. 
  3. ^ Shan, Tony (2006-10-24). "Taxonomy of Java Web Application Frameworks". Proceedings of 2006 IEEE International Conference on e-Business Engineering (ICEBE 2006). http://portal.acm.org/citation.cfm?id=1190953. Retrieved 2010-10-10. 
  4. ^ Carleton, Daniel (2007-10-12). "Java Web Development the Wicket Way". DevX. http://www.devx.com/Java/Article/35620. Retrieved 2008-03-07. 
  5. ^ http://wicket.apache.org/2009/07/30/wicket-1.3.7-released.html
  6. ^ http://wicket.apache.org/2009/07/30/wicket-1.4-takes-typesafety-to-the-next-level.html
  7. ^ http://wicket.apache.org/2009/08/21/wicket-1.4.1-released.html
  8. ^ http://wicket.apache.org/2010/05/24/wicket-1.4.9-released.html
  9. ^ http://wicket.apache.org/2010/08/11/wicket-1.4.10-released.html
  10. ^ http://wicket.apache.org/2011/02/25/wicket-1.4.16-released.html
  11. ^ http://wicket.apache.org/2011/04/02/wicket-1.4.17-released.html
  12. ^ http://wicket.apache.org/2011/08/09/wicket-1.4.18-released.html
  13. ^ http://wicket.apache.org/2011/10/17/wicket-1.4.19-released.html
  14. ^ http://wicket.apache.org/2011/09/07/wicket-1.5-released.html
  15. ^ http://wicket.apache.org/2011/09/29/wicket-1.5.1-released.html
  16. ^ http://wicket.apache.org/2011/10/24/wicket-1.5.2-released.html
  17. ^ http://wicket.apache.org/2011/11/14/wicket-1.5.3-release.html
  18. ^ http://apache-wicket.1842946.n4.nabble.com/Roadmap-for-Wicket-6-td3777610.html

Bibliography

External links

Introductory articles

Blogs

Documentation